<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>

<div id="app">
  <my_count></my_count>
  <my_count></my_count>
  <my_count></my_count>
</div>
<template id="cpn">
  <div>
    <h2>当前计数：{{counter}}</h2>
    <button @click="increment">+</button>
    <button @click="decrement">-</button>
  </div>
</template>
<!--引入vue-->
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<script>
  Vue.component('my_count', {
    template: '#cpn',
    data() {
      return {
        counter: 0
      }
    },
    methods: {
      increment() {
        this.counter++;
      },
      decrement() {
        this.counter--;
      }
    }
  })
  const app = new Vue({
    el: "#app",
    data() {

    }
  })
</script>
</body>
</html>
